package com.miwzn.boot.modules.sys.web;

import com.miwzn.base.AbstractController;
import com.miwzn.boot.modules.sys.entity.po.SysRole;
import com.miwzn.boot.modules.sys.entity.qm.SysRoleQuery;
import com.miwzn.boot.modules.sys.entity.dto.SysRoleDto;
import com.miwzn.boot.modules.sys.service.SysRoleService;
import com.miwzn.comm.ResponseEntity;
import com.miwzn.comm.annotation.OperationLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: wzn
 * @Date: 2018-12-27 15:17:28
 * @Description: www.miwzn.com mvc api
 */
@ResponseBody
@Controller
@RequestMapping("sys/role")
public class SysRoleController extends AbstractController<SysRole, SysRoleDto, SysRoleQuery> {
    private static Logger logger = LoggerFactory.getLogger(SysRoleController.class);

    @Autowired
    private SysRoleService sysRoleService;

    /**
     * 根据ID获取信息
     *
     * @param id
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="根据ID获取角色")
    @RequiresPermissions("sys:role:getById")
    @GetMapping("/getById/{id}")
    public ResponseEntity getById(@PathVariable("id") String id) {
        return super.getById(id);
    }

    /**
     * 列表
     *
     * @param entity
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="获取角色列表")
    @RequiresPermissions("sys:role:list")
    @GetMapping("/list")
    public ResponseEntity list(SysRoleQuery entity) {
        return super.listD(entity);
    }

    /**
     * 添加
     *
     * @param entity
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="添加角色")
    @RequiresPermissions("sys:role:add")
    @PostMapping("add")
    public ResponseEntity add(@RequestBody SysRoleDto entity) {
        return super.add(entity);
    }

    /**
     * 更新
     *
     * @param entity
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="更新角色")
    @RequiresPermissions("sys:role:update")
    @PutMapping("update")
    public ResponseEntity update(@RequestBody SysRoleDto entity) {
        return super.update(entity);
    }

    /**
     * 软删除
     *
     * @param id
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="删除角色")
    @RequiresPermissions("sys:role:delFlag")
    @DeleteMapping("/delFlag/{id}")
    public ResponseEntity deleteFlag(@PathVariable("id") String id) {
        return super.deleteFlag(id);
    }

    /**
     * 软删除
     *
     * @param ids
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="删除角色")
    @RequiresPermissions("sys:role:delFlag")
    @DeleteMapping("/delFlag")
    public ResponseEntity deleteFlag(@RequestBody String[] ids ) {
        return super.deleteFlag(ids);
    }

    /**
     * 硬删除
     *
     * @param id
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="删除角色")
    @RequiresPermissions("sys:role:del")
    @DeleteMapping("/del/{id}")
    public ResponseEntity delete(@PathVariable("id") String id) {
        return super.delete(id);
    }

    /**
     * 硬删除
     *
     * @param ids
     *
     * @return
     */
    @OperationLog(operation = "系统-角色",content ="删除角色")
    @RequiresPermissions("sys:role:del")
    @DeleteMapping("/del")
    public ResponseEntity delete(@RequestBody String[] ids ) {
        return super.delete(ids);
    }

}
